x11: Set surface position correctly
authorMatthias Clasen <mclasen@redhat.com>
Wed, 29 May 2019 04:31:04 +0000 (00:31 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 29 May 2019 18:04:08 +0000 (18:04 +0000)
The X backend was storing global coordinates
in surface->x/y, and keeping the parent-relative
positions in its own fields. Switch this around
to store the relative position in x/y, as is
expected by the frontend.

gdk/x11/gdksurface-x11.c
gdk/x11/gdksurface-x11.h

index d98b4e6bbf4981d8e2525940d27ff6ba47d2e9e4..aa5082f6bfb81c0c9e5cf80c0472d65bf3c06ed8 100644 (file)
@@ -1271,13 +1271,18 @@ x11_surface_move (GdkSurface *surface,
 
   if (impl->override_redirect)
     {
-      surface->x = x;
-      surface->y = y;
+      impl->abs_x = x;
+      impl->abs_y = y;
 
       if (surface->parent)
         {
-          impl->offset_x = surface->x - surface->parent->x;
-          impl->offset_y = surface->y - surface->parent->y;
+          surface->x = impl->abs_x - GDK_X11_SURFACE (surface->parent)->abs_x;
+          surface->y = impl->abs_y - GDK_X11_SURFACE (surface->parent)->abs_y;
+        }
+      else
+        {
+          surface->x = x;
+          surface->y = y;
         }
     }
 }
@@ -1340,8 +1345,8 @@ x11_surface_move_resize (GdkSurface *surface,
 
   if (impl->override_redirect)
     {
-      surface->x = x;
-      surface->y = y;
+      impl->abs_x = x;
+      impl->abs_y = y;
 
       impl->unscaled_width = width * impl->surface_scale;
       impl->unscaled_height = height * impl->surface_scale;
@@ -1352,8 +1357,13 @@ x11_surface_move_resize (GdkSurface *surface,
 
       if (surface->parent)
         {
-          impl->offset_x = surface->x - surface->parent->x;
-          impl->offset_y = surface->y - surface->parent->y;
+          surface->x = impl->abs_x - GDK_X11_SURFACE (surface->parent)->abs_x;
+          surface->y = impl->abs_y - GDK_X11_SURFACE (surface->parent)->abs_y;
+        }
+      else
+        {
+          surface->x = x;
+          surface->y = y;
         }
     }
   else
@@ -1395,10 +1405,10 @@ gdk_x11_surface_update_popups (GdkSurface *parent)
     {
       GdkX11Surface *popup_impl = l->data;
       GdkSurface *popup = GDK_SURFACE (popup_impl);
-      int new_x = parent->x + popup_impl->offset_x;
-      int new_y = parent->y + popup_impl->offset_y;
+      int new_x = GDK_X11_SURFACE (parent)->abs_x + popup->x;
+      int new_y = GDK_X11_SURFACE (parent)->abs_y + popup->y;
 
-      if (new_x != popup->x || new_y != popup->y)
+      if (new_x != popup_impl->abs_x || new_y != popup_impl->abs_y)
         x11_surface_move (popup, new_x, new_y);
       gdk_x11_surface_restack_toplevel (popup, parent, TRUE);
     }
@@ -2346,8 +2356,8 @@ gdk_x11_surface_get_frame_extents (GdkSurface    *surface,
   impl = GDK_X11_SURFACE (surface);
 
   /* Refine our fallback answer a bit using local information */
-  rect->x = surface->x * impl->surface_scale;
-  rect->y = surface->y * impl->surface_scale;
+  rect->x = impl->abs_x * impl->surface_scale;
+  rect->y = impl->abs_y * impl->surface_scale;
   rect->width = surface->width * impl->surface_scale;
   rect->height = surface->height * impl->surface_scale;
 
index 6c6744a71d839c8a2d9600148b9f389ea7003e3d..c890d6c13fefc487eeed5ef4191a3206c4aaeb93 100644 (file)
@@ -76,8 +76,8 @@ struct _GdkX11Surface
   Damage damage;
 #endif
 
-  int offset_x;
-  int offset_y;
+  int abs_x;
+  int abs_y;
 };
  
 struct _GdkX11SurfaceClass